﻿using Youz.Common.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Youz.Common.BLL
{
    public class BaseBLL
    {
        /// <summary>
        /// 菜单名
        /// </summary>
        public string MenuName
        {
            get;
            set;
        }

        /// <summary>
        /// 模块名
        /// </summary>
        public string ModuleName
        {
            get;
            set;
        }

        public void WriteOperationLog(OperationType type, bool result, object log)
        {
            WriteOperationLog(type.ToString(), result, log.ToString());
        }

        public void WriteOperationLog(string type, bool result, string log)
        {
            Utility.WriteOperationLog(this.MenuName, this.ModuleName, type, result, log);
        }

        /// <summary>
        /// 敏感操作记录
        /// </summary>
        /// <param name="type"></param>
        /// <param name="result"></param>
        /// <param name="log"></param>
        /// <param name="Sensitive">1敏感操作,0非敏感操作</param>
        /// <param name="OperatingDetails">操作明细</param>
        public void WriteOperationLogSensitive(OperationType type, bool result, object log, int Sensitive, string OperatingDetails)
        {
            Utility.WriteOperationLog(this.MenuName, this.ModuleName, type.ToString(), result, log.ToString(), Sensitive, OperatingDetails);
        }

        /// <summary>
        /// 审核的状态是否已变更
        /// </summary>
        /// <param name="last"></param>
        /// <param name="current"></param>
        /// <returns></returns>
        public bool IsAudit(AuditStatus last, AuditStatus current)
        {
            return ((last == AuditStatus.Waiting || last == AuditStatus.Auditing) && (current == AuditStatus.Pass || current == AuditStatus.Refuse))
                || (last == AuditStatus.Waiting && current == AuditStatus.Auditing);
        }

        public static string R(LanguageModule module, string key)
        {
            return Lang_LanguageBLL.LanguageByManage(module, key);
        }

        public static string R(LanguageModule module, string key, string defaultValue)
        {
            return Lang_LanguageBLL.LanguageByManage(module, key, defaultValue);
        }
    }
}
